<%--
  Created by IntelliJ IDEA.
  User: 12100
  Date: 2024/8/16
  Time: 19:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>图书列表页面</title>

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>

        <title>图书管理界面</title>
        <%
            String base = request.getContextPath() + "/";
            String url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + base;
        %>
        <base href="<%=url%>">
        <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                $("[type='button']").click(function () {
                    var index = $("select").val();
                    var str = $("[name='qval']").val();
                    $.get("book/queryByBook",{"query": index, "str": str}, function (books) {
                        JSON.stringify(books);
                        forBooks(books)
                    });
                });
                $.get("book/queryByBook", function (books) {
                    JSON.stringify(books);
                    forBooks(books)
                });
            });
            function forBooks(books) {
                $("tbody").empty();
                for (var i = 0; i < books.length; i++) {
                    $("<tr>" +
                        "<td>" + books[i].bookName + "</td>" +
                        "<td>" + books[i].bookAuthor + "</td>" +
                        "<td>" + books[i].bookPublish + "</td>" +
                        "<td>" + books[i].bookPage + "</td>" +
                        "<td>" + books[i].bookPrice + "</td>" +
                        "<td><a name='" + books[i].bookId + "' title='删除'>删除/</a><a name='" + books[i].bookId + "'>修改</a></td>" +
                        "</tr>").appendTo("tbody");
                }
            }
        </script>
    </head>
<body>
<h1>图书管理界面</h1>
<select name="query">
    <option value="-1" name="str">请选择</option>
    <option value="1" name="str">书名</option>
    <option value="2" name="str">作者名</option>
    <option value="3" name="str">出版社名</option>
</select>
<input type="text" name="qval">
<input type="button" value="查询">

<table border="1px">
    <thead>
    <tr style="background-color: red">

        <td>书名</td>
        <td>作者</td>
        <td>出版社</td>
        <td>页数</td>
        <td>价格</td>
        <td>操作</td>
    </tr>
    </thead>

    <tbody>


    </tbody>

</table>
</body>
</html>
